﻿Imports System
Imports System.ComponentModel
Imports System.Drawing.Design
Imports System.Security.Permissions
Imports System.Windows.Forms
Imports System.Windows.Forms.Design
Imports System.Workflow.ComponentModel.Design

Namespace System.Workflow.Activities
    <PermissionSet(SecurityAction.LinkDemand, Name:="FullTrust")> _
    Friend NotInheritable Class WebServicePickerEditor
        Inherits UITypeEditor
        ' Methods
        Public Overrides Function EditValue(ByVal typeDescriptorContext As ITypeDescriptorContext, ByVal serviceProvider As IServiceProvider, ByVal o As Object) As Object
            Dim obj2 As Object = o
            Me.editorService = DirectCast(serviceProvider.GetService(GetType(IWindowsFormsEditorService)), IWindowsFormsEditorService)
            Dim service As IExtendedUIService = DirectCast(serviceProvider.GetService(GetType(IExtendedUIService)), IExtendedUIService)
            If ((Not Me.editorService Is Nothing) AndAlso (Not service Is Nothing)) Then
                Dim url As Uri = Nothing
                Dim proxyClass As Type = Nothing
                If (DialogResult.OK = service.AddWebReference(url, proxyClass)) Then
                    obj2 = If((Not url Is Nothing), url.ToString, String.Empty)
                    typeDescriptorContext.PropertyDescriptor.SetValue(typeDescriptorContext.Instance, [TryCast](obj2,String))
                End If
            End If
            Return obj2
        End Function

        Public Overrides Function GetEditStyle(ByVal typeDescriptorContext As ITypeDescriptorContext) As UITypeEditorEditStyle
            Return UITypeEditorEditStyle.Modal
        End Function


        ' Fields
        Private editorService As IWindowsFormsEditorService
    End Class
End Namespace

